home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / Label3D.java < prev    next >
Text File  |  1998-08-21  |  23KB  |  766 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Canvas;
  5. import java.awt.Dimension;
  6. import java.awt.Color;
  7. import java.awt.FontMetrics;
  8. import java.awt.Font;
  9. import java.awt.Rectangle;
  10. import java.awt.Graphics;
  11. import java.beans.PropertyVetoException;
  12. import java.beans.PropertyChangeListener;
  13. import java.beans.VetoableChangeListener;
  14. import java.beans.PropertyChangeEvent;
  15. import symantec.itools.awt.util.ColorUtils;
  16. import symantec.itools.beans.VetoableChangeSupport;
  17. import symantec.itools.beans.PropertyChangeSupport;
  18.  
  19. //    01/29/97    TWB    Integrated changes from Windows
  20. //     01/29/97    TWB    Integrated changes from Macintosh
  21. //  05/11/97    CAR Added getBorderedColor
  22. //    06/01/97    RKM    Updated to support Java 1.1
  23. //                    Changed invalidate to repaint
  24. //  07/29/97    CAR marked fields transient as needed
  25. //  08/05/97    LAB Updated version number to 1.1.  Now uses ColorUtils.calculateHilightColor
  26. //                    and ColorUtils.calculateShadowColor to calculate the bevel colors more
  27. //                    intelligently.  Deprecated preferredSize and minimumSize in favor of
  28. //                    getPreferredSize and getMinimumSize.  Made lightweight.  Moved color
  29. //                    determination code into paint().  Removed color1 and color2 data members.
  30. //                    Made some protected data private and some private data protected.
  31. //                    Addressed Mac Bug #2771.
  32. //  08/12/97    LAB Removed overriden reshape.  Made paint set the font of the graphics
  33. //                    to the container's font.  This addresses Mac Bug #7237.
  34. //    08/15/97    LAB    Reworked the way colors were calculated to avoid NullPointerExceptions,
  35. //                    and potential redraw problems.  Now colors are recalculated in paint,
  36. //                    if needed.
  37.  
  38. /**
  39.  * Creates a text string in a rectangle that has a three-dimensional visual
  40.  * effect. It is usually attached to an option, box, or button.
  41.  * <p>
  42.  * An application or applet can change the label text string, but a user
  43.  * cannot edit it.
  44.  * <p>
  45.  * Note: For most components, labels are usually created by specifying text
  46.  * for the Label property of that component.
  47.  * <p>
  48.  * @version 1.1, August 5, 1997
  49.  * @author Symantec
  50.  */
  51. public class Label3D extends Component implements AlignStyle, BevelStyle
  52. {
  53.     /**
  54.      * Constant indicating a drawing margin of 0 pixels around the outside of
  55.      * the border.
  56.      */
  57.     public static final int INDENT_ZERO = 0;
  58.  
  59.     /**
  60.      * Constant indicating a drawing margin of 1 pixel around the outside of
  61.      * the border.
  62.      */
  63.     public static final int INDENT_ONE = 1;
  64.  
  65.     /**
  66.      * Constant indicating a drawing margin of 2 pixels around the outside of
  67.      * the border.
  68.      */
  69.     public static final int INDENT_TWO = 2;
  70.  
  71.     //
  72.     // Constructors
  73.     //
  74.  
  75.     /**
  76.      * Constructs an empty Label3D with black text that is center aligned
  77.      * and a raised border with zero border indent.
  78.      */
  79.     public Label3D()
  80.     {
  81.         this("", ALIGN_CENTERED, BEVEL_RAISED, Color.black, INDENT_ZERO);
  82.     }
  83.  
  84.     /**
  85.      * Constructs a Label3D with black text, zero border indent, and the
  86.      * specified text alignment and bevel styles.
  87.      * @param sText the label text
  88.      * @param alignStyle the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  89.      * @param bevelStyle the bevel style: BEVEL_RAISED, BEVEL_LOWERED, BEVEL_LINE, or BEVEL_NONE
  90.      * @see AlignStyle#ALIGN_LEFT
  91.      * @see AlignStyle#ALIGN_CENTERED
  92.      * @see AlignStyle#ALIGN_RIGHT
  93.      * @see BevelStyle#BEVEL_RAISED
  94.      * @see BevelStyle#BEVEL_LOWERED
  95.      * @see BevelStyle#BEVEL_LINE
  96.      * @see BevelStyle#BEVEL_NONE
  97.      */
  98.     public Label3D(String sText, int alignStyle, int bevelStyle)
  99.     {
  100.         this(sText, alignStyle, bevelStyle, Color.black, INDENT_ZERO);
  101.     }
  102.  
  103.     /**
  104.      * Constructs a Label3D with a zero border indent and the specified attributes.
  105.      * @param sText the label text
  106.      * @param alignStyle the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  107.      * @param bevelStyle the bevel style: BEVEL_RAISED, BEVEL_LOWERED, BEVEL_LINE, or BEVEL_NONE
  108.      * @param color the text color
  109.      * @see AlignStyle#ALIGN_LEFT
  110.      * @see AlignStyle#ALIGN_CENTERED
  111.      * @see AlignStyle#ALIGN_RIGHT
  112.      * @see BevelStyle#BEVEL_RAISED
  113.      * @see BevelStyle#BEVEL_LOWERED
  114.      * @see BevelStyle#BEVEL_LINE
  115.      * @see BevelStyle#BEVEL_NONE
  116.      */
  117.     public Label3D(String sText, int alignStyle, int bevelStyle, Color color)
  118.     {
  119.         this(sText, alignStyle, bevelStyle, color, INDENT_ZERO);
  120.     }
  121.  
  122.     /**
  123.      * Constructs a Label3D with black text and the specified attributes.
  124.      * @param sText the label text
  125.      * @param alignStyle the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  126.      * @param bevelStyle the bevel style: BEVEL_RAISED, BEVEL_LOWERED, BEVEL_LINE, or BEVEL_NONE
  127.      * @param indent the amount to indent the border: INDENT_ZERO,
  128.      * INDENT_ONE,  or INDENT_TWO
  129.      * @see AlignStyle#ALIGN_LEFT
  130.      * @see AlignStyle#ALIGN_CENTERED
  131.      * @see AlignStyle#ALIGN_RIGHT
  132.      * @see BevelStyle#BEVEL_RAISED
  133.      * @see BevelStyle#BEVEL_LOWERED
  134.      * @see BevelStyle#BEVEL_LINE
  135.      * @see BevelStyle#BEVEL_NONE
  136.      * @see #INDENT_ZERO
  137.      * @see #INDENT_ONE
  138.      * @see #INDENT_TWO
  139.      */
  140.     public Label3D(String sText, int alignStyle, int bevelStyle, int indent)
  141.     {
  142.         this(sText, alignStyle, bevelStyle, Color.black, indent);
  143.     }
  144.  
  145.     /**
  146.      * Constructs a Label3D with the specified attributes.
  147.      * @param sText the label text
  148.      * @param alignStyle the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  149.      * @param bevelStyle the bevel style: BEVEL_RAISED, BEVEL_LOWERED, BEVEL_LINE, or BEVEL_NONE
  150.      * @param color the text color
  151.      * @param indent the amount to indent the border: INDENT_ZERO,
  152.      * INDENT_ONE,  or INDENT_TWO
  153.      * @see AlignStyle#ALIGN_LEFT
  154.      * @see AlignStyle#ALIGN_CENTERED
  155.      * @see AlignStyle#ALIGN_RIGHT
  156.      * @see BevelStyle#BEVEL_RAISED
  157.      * @see BevelStyle#BEVEL_LOWERED
  158.      * @see BevelStyle#BEVEL_LINE
  159.      * @see BevelStyle#BEVEL_NONE
  160.      * @see #INDENT_ZERO
  161.      * @see #INDENT_ONE
  162.      * @see #INDENT_TWO
  163.      */
  164.     public Label3D(String sText, int alignStyle, int bevelStyle, Color color, int indent)
  165.     {
  166.         String sOs = System.getProperty("os.name");
  167.  
  168.         if (sOs.startsWith("S") ||      // SunOS, Solaris
  169.             sOs.startsWith("OSF") )     // OSF
  170.         {
  171.             bOsFlag = true;
  172.             setFont(new Font("Dialog", Font.PLAIN, 10));
  173.         }
  174.         else
  175.         {
  176.             bOsFlag = false;
  177.         }
  178.  
  179.         sLabel3D = sText;
  180.         textColor = color;
  181.         borderedColor = Color.black;
  182.         cachedBackground = getBackground();
  183.         
  184.         try
  185.         {
  186.             setBorderIndent(indent);
  187.             setAlignStyle(alignStyle);
  188.             setBevelStyle(bevelStyle);
  189.         }
  190.         catch(PropertyVetoException veto) {};
  191.     }
  192.  
  193.     //
  194.     // Properties
  195.     //
  196.  
  197.     /**
  198.      * Sets the text alignment style.
  199.      * @param style the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  200.      * @see #getAlignStyle
  201.      * @see AlignStyle#ALIGN_LEFT
  202.      * @see AlignStyle#ALIGN_CENTERED
  203.      * @see AlignStyle#ALIGN_RIGHT
  204.      * @exception PropertyVetoException
  205.      * if the specified property value is unacceptable
  206.      */
  207.     public void setAlignStyle(int newAlignStyle) throws PropertyVetoException
  208.     {
  209.         if (alignStyle != newAlignStyle)
  210.         {
  211.             Integer oldAlignStyleInt = new Integer(alignStyle);
  212.             Integer newAlignStyleInt = new Integer(newAlignStyle);
  213.  
  214.             vetos.fireVetoableChange("AlignStyle",oldAlignStyleInt,newAlignStyleInt);
  215.  
  216.             alignStyle = newAlignStyle;
  217.             repaint();
  218.  
  219.             changes.firePropertyChange("AlignStyle",oldAlignStyleInt,newAlignStyleInt);
  220.         }
  221.     }
  222.  
  223.     /**
  224.      * Gets the current alignment style.
  225.      * @return the text alignment style: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT
  226.      * @see #setAlignStyle
  227.      * @see AlignStyle#ALIGN_LEFT
  228.      * @see AlignStyle#ALIGN_CENTERED
  229.      * @see AlignStyle#ALIGN_RIGHT
  230.      */
  231.     public int getAlignStyle()
  232.     {
  233.         return alignStyle;
  234.     }
  235.  
  236.     /**
  237.      * Sets the border style.
  238.      * @param style the border bevel style: BEVEL_RAISED, BEVEL_LOWERED, BEVEL_LINE, or BEVEL_NONE
  239.      * @see #getBevelStyle
  240.      * @see BevelStyle#BEVEL_RAISED
  241.      * @see BevelStyle#BEVEL_LOWERED
  242.      * @see BevelStyle#BEVEL_LINE
  243.      * @see BevelStyle#BEVEL_NONE
  244.      * @exception PropertyVetoException
  245.      * if the specified property value is unacceptable
  246.      */
  247.     public void setBevelStyle(int newBevelStyle) throws PropertyVetoException
  248.     {
  249.         if (bevelStyle != newBevelStyle)
  250.         {
  251.             Integer oldValue = new Integer(bevelStyle);
  252.             Integer newValue = new Integer(newBevelStyle);
  253.  
  254.             vetos.fireVetoableChange("BevelStyle", oldValue, newValue);
  255.  
  256.             bevelStyle = newBevelStyle;
  257.  
  258.             repaint();
  259.  
  260.             changes.firePropertyChange("BevelStyle", oldValue, newValue);
  261.  
  262.         }
  263.     }
  264.  
  265.     /**
  266.      * Gets the current border style.
  267.      * @return the border bevel style: BEVEL_RAISED, BEVEL_LOWERED, BEVEL_LINE, or BEVEL_NONE
  268.      * @see #setBevelStyle
  269.      * @see BevelStyle#BEVEL_RAISED
  270.      * @see BevelStyle#BEVEL_LOWERED
  271.      * @see BevelStyle#BEVEL_LINE
  272.      * @see BevelStyle#BEVEL_NONE
  273.      */
  274.     public int getBevelStyle()
  275.     {
  276.         return bevelStyle;
  277.     }
  278.  
  279.     /**
  280.      * Sets the border indent amount.
  281.      * @param newBorderIndent the amount to indent around the border: INDENT_ZERO,
  282.      * INDENT_ONE,  or INDENT_TWO
  283.      * @see #getBorderIndent
  284.      * @see #INDENT_ZERO
  285.      * @see #INDENT_ONE
  286.      * @see #INDENT_TWO
  287.      * @exception PropertyVetoException
  288.      * if the specified property value is unacceptable
  289.      */
  290.     public void setBorderIndent(int newBorderIndent) throws PropertyVetoException
  291.     {
  292.         //Constrain newBorderIndent
  293.         if (newBorderIndent < INDENT_ZERO)
  294.             newBorderIndent = INDENT_ZERO;
  295.         else if (newBorderIndent > INDENT_TWO)
  296.             newBorderIndent = INDENT_TWO;
  297.  
  298.         if (indent != newBorderIndent)
  299.         {
  300.             Integer oldBorderIndentInt = new Integer(indent);
  301.             Integer newBorderIndentInt = new Integer(newBorderIndent);
  302.  
  303.             vetos.fireVetoableChange("BorderIndent",oldBorderIndentInt,newBorderIndentInt);
  304.  
  305.             indent = newBorderIndent;
  306.             repaint();
  307.  
  308.             changes.firePropertyChange("BorderIndent",oldBorderIndentInt,newBorderIndentInt);
  309.         }
  310.     }
  311.  
  312.     /**
  313.      * Gets the current border indent amount.
  314.      * @return the amount the border is currently indented: INDENT_ZERO,
  315.      * INDENT_ONE,  or INDENT_TWO
  316.      * @see #setBorderIndent
  317.      * @see #INDENT_ZERO
  318.      * @see #INDENT_ONE
  319.      * @see #INDENT_TWO
  320.      */
  321.     public int getBorderIndent()
  322.     {
  323.         return indent;
  324.     }
  325.  
  326.     /**
  327.      * Sets the border color.
  328.      * @param newBorderColor the color to use for the border
  329.      * @exception PropertyVetoException
  330.      * if the specified property value is unacceptable
  331.      */
  332.     public void setBorderedColor(Color newBorderColor) throws PropertyVetoException
  333.     {
  334.         if (!symantec.itools.util.GeneralUtils.objectsEqual(borderedColor,newBorderColor))
  335.         {
  336.             Color oldBorderColor = borderedColor;
  337.  
  338.             vetos.fireVetoableChange("BorderedColor",oldBorderColor,newBorderColor);
  339.  
  340.             borderedColor = newBorderColor;
  341.  
  342.             repaint();
  343.  
  344.             changes.firePropertyChange("BorderedColor",oldBorderColor,newBorderColor);
  345.  
  346.         }
  347.     }
  348.  
  349.     /**
  350.      * Gets the border color.
  351.      * @return the border color
  352.      * @see #setBorderedColor
  353.      */
  354.     public Color getBorderedColor()
  355.     {
  356.         return borderedColor;
  357.     }
  358.  
  359.     /**
  360.      * Sets the label text.
  361.      * @param newText the new label text
  362.      * @see #getText
  363.      * @exception PropertyVetoException
  364.      * if the specified property value is unacceptable
  365.      */
  366.     public void setText(String newText) throws PropertyVetoException
  367.     {
  368.         if (!symantec.itools.util.GeneralUtils.objectsEqual(sLabel3D,newText))
  369.         {
  370.             String oldText = sLabel3D;
  371.  
  372.             vetos.fireVetoableChange("Text",oldText,newText);
  373.  
  374.             sLabel3D = newText;
  375.             repaint();
  376.  
  377.             changes.firePropertyChange("Text",oldText,newText);
  378.         }
  379.     }
  380.  
  381.     /**
  382.      * Gets the current label text.
  383.      * @return the current label text
  384.      * @see #setText
  385.      */
  386.     public String getText()
  387.     {
  388.         return sLabel3D;
  389.     }
  390.  
  391.     /**
  392.      * Sets the label text color.
  393.      * @param newTextColor the new color for the label text
  394.      * @see #getTextColor
  395.      * @exception PropertyVetoException
  396.      * if the specified property value is unacceptable
  397.      */
  398.     public void setTextColor(Color newTextColor) throws PropertyVetoException
  399.     {
  400.         if (!symantec.itools.util.GeneralUtils.objectsEqual(textColor,newTextColor))
  401.         {
  402.             Color oldValue = textColor;
  403.  
  404.             vetos.fireVetoableChange("TextColor", oldValue, newTextColor);
  405.  
  406.             textColor = newTextColor;
  407.             repaint();
  408.  
  409.             changes.firePropertyChange("TextColor", oldValue, newTextColor);
  410.         }
  411.     }
  412.  
  413.     /**
  414.      * Gets the current label text color.
  415.      * @return the current color of the label text
  416.      * @see #setTextColor
  417.      */
  418.     public Color getTextColor()
  419.     {
  420.         return textColor;
  421.     }
  422.  
  423.     /**
  424.      * Paints this component using the given graphics context.
  425.      * This is a standard Java AWT method which typically gets called
  426.      * by the AWT to handle painting this component. It paints this component
  427.      * using the given graphics context. The graphics context clipping region
  428.      * is set to the bounding rectangle of this component and its [0,0]
  429.      * coordinate is this component's top-left corner.
  430.      *
  431.      * @param g the graphics context used for painting
  432.      * @see java.awt.Component#repaint
  433.      * @see java.awt.Component#update
  434.      */
  435.     public void paint(Graphics g)
  436.     {
  437.         Rectangle r;
  438.         Color c, color1, color2;
  439.  
  440.         Color curBackground = getBackground();
  441.         if (!symantec.itools.util.GeneralUtils.objectsEqual(curBackground, cachedBackground))
  442.         {
  443.             cachedBackground = curBackground;
  444.             calculateHilightColors(curBackground);
  445.         }
  446.         
  447.         r = bounds();
  448.         c = g.getColor();
  449.         
  450.         g.setFont(getFont());
  451.         
  452.         switch (bevelStyle)
  453.         {
  454.             case BEVEL_LOWERED :
  455.             {
  456.                 color1 = shadowColor;
  457.                 color2 = hilightColor;
  458.                 break;
  459.             }
  460.  
  461.             case BEVEL_RAISED :
  462.             {
  463.                 color1 = hilightColor;
  464.                 color2 = shadowColor;
  465.                 break;
  466.             }
  467.  
  468.             case BEVEL_LINE :
  469.             {
  470.                 color1 = borderedColor;
  471.                 color2 = borderedColor;
  472.                 break;
  473.             }
  474.  
  475.             default: // catches any bogus type, paint(...) relies on color1 being null
  476.             {
  477.                 color1 = color2 = null;
  478.                 break;
  479.             }
  480.         }
  481.  
  482.         g.setColor(getBackground());
  483.         g.fillRect(0, 0, r.width - 1, r.height - 1);
  484.  
  485.         if (color1 != null)
  486.         {
  487.             // top
  488.             g.setColor(color1);
  489.             g.drawLine(1+indent, indent, r.width-3-indent, indent);
  490.  
  491.             // bottom
  492.             g.setColor(color2);
  493.             g.drawLine(1+indent, r.height-1-indent, r.width-3-indent, r.height-1-indent);
  494.  
  495.             // left
  496.             g.setColor(color1);
  497.             g.drawLine(indent, indent, indent, r.height-1-indent);
  498.  
  499.             // right
  500.             g.setColor(color2);
  501.             g.drawLine(r.width-2-indent, indent, r.width-2-indent, r.height-1-indent);
  502.  
  503.             g.clipRect(2 + indent, 1+indent, r.width-9-indent, r.height-4-indent);
  504.             yTemp = 1 + indent;
  505.         }
  506.         else
  507.         {
  508.             g.drawRect(indent, indent, r.width-2-indent, r.height-1-indent);
  509.             g.clipRect(2, 1, r.width-7, r.height-2);
  510.             yTemp = 1;
  511.         }
  512.  
  513.         // text
  514.         g.setColor(textColor);
  515.  
  516.         fm = getFontMetrics(g.getFont());
  517.         yTemp = (r.height - yTemp + fm.getAscent()) / 2;
  518.  
  519.         switch (alignStyle)
  520.         {
  521.             case ALIGN_LEFT:
  522.             {
  523.                 if (bevelStyle == BEVEL_LINE)
  524.                 {
  525.                     g.drawString(sLabel3D, 4, yTemp);
  526.                 }
  527.                 else
  528.                 {
  529.                     g.drawString(sLabel3D, 8, yTemp);
  530.                 }
  531.  
  532.                 break;
  533.             }
  534.  
  535.             case ALIGN_RIGHT:
  536.             {
  537.                 xTemp = r.width - fm.stringWidth(sLabel3D);
  538.  
  539.                 if (bevelStyle == BEVEL_LINE)
  540.                 {
  541.                     g.drawString(sLabel3D, xTemp - 6, yTemp);
  542.                 }
  543.                 else
  544.                 {
  545.                     g.drawString(sLabel3D, xTemp - 10, yTemp);
  546.                 }
  547.  
  548.                 break;
  549.             }
  550.  
  551.             case ALIGN_CENTERED:
  552.             {
  553.                 xTemp = (r.width - fm.stringWidth(sLabel3D)) / 2;
  554.                 g.drawString(sLabel3D, xTemp, yTemp);
  555.  
  556.                 break;
  557.             }
  558.         }
  559.  
  560.         // reset color
  561.         g.setColor(c);
  562.     }
  563.  
  564.     /**
  565.      * Returns the recommended dimensions to properly display this component.
  566.      * This is a standard Java AWT method which gets called to determine
  567.      * the recommended size of this component.
  568.      *
  569.      * For each axis, the preferred size is the maximum of the current size
  570.      * and the minimum size needed to display the entire label text.
  571.      *
  572.      * @see #getMinimumSize
  573.      */
  574.     public Dimension getPreferredSize()
  575.     {
  576.         Dimension s = size();
  577.         Dimension m = minimumSize();
  578.  
  579.         return new Dimension(Math.max(s.width, m.width), Math.max(s.height, m.height));
  580.     }
  581.  
  582.     /**
  583.      * @deprecated
  584.      * @see #getPreferredSize
  585.      */
  586.     public Dimension preferredSize()
  587.     {
  588.         return getPreferredSize();
  589.     }
  590.  
  591.     /**
  592.      * Returns the minimum dimensions to properly display this component.
  593.      * This is a standard Java AWT method which gets called to determine
  594.      * the minimum size of this component.
  595.      *
  596.      * The minimum size is that size needed to display the entire label text.
  597.      *
  598.      * @see #getPreferredSize
  599.      */
  600.     public Dimension getMinimumSize()
  601.     {
  602.         Dimension min;
  603.         Font f;
  604.  
  605.         min = new Dimension(18, 10);
  606.         f   = getFont();
  607.  
  608.         if (f == null)
  609.         {
  610.             if (bOsFlag)
  611.             {
  612.                 min.height = 29;
  613.             }
  614.         }
  615.         else
  616.         {
  617.             fm = getFontMetrics(f);
  618.             min.width = fm.stringWidth(sLabel3D) + 18;
  619.             min.height = fm.getHeight() + 10;
  620.  
  621.             if (bOsFlag && min.height < 29)
  622.             {
  623.                 min.height = 29;
  624.             }
  625.         }
  626.  
  627.         return min;
  628.     }
  629.  
  630.     /**
  631.      * @deprecated
  632.      * @see #getMinimumSize
  633.      */
  634.     public Dimension minimumSize()
  635.     {
  636.         return getMinimumSize();
  637.     }
  638.  
  639.     /**
  640.      * Adds a listener for all event changes.
  641.      * @param listener the listener to add.
  642.      * @see #removePropertyChangeListener
  643.      */
  644.     public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
  645.     {
  646.         //super.addPropertyChangeListener(listener);
  647.         changes.addPropertyChangeListener(listener);
  648.     }
  649.  
  650.     /**
  651.      * Removes a listener for all event changes.
  652.      * @param listener the listener to remove.
  653.      * @see #addPropertyChangeListener
  654.      */
  655.     public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
  656.     {
  657.         //super.removePropertyChangeListener(listener);
  658.         changes.removePropertyChangeListener(listener);
  659.     }
  660.  
  661.     /**
  662.      * Adds a vetoable listener for all event changes.
  663.      * @param listener the listener to add.
  664.      * @see #removeVetoableChangeListener
  665.      */
  666.     public synchronized void addVetoableChangeListener(VetoableChangeListener listener)
  667.     {
  668.          //super.addVetoableChangeListener(listener);
  669.         vetos.addVetoableChangeListener(listener);
  670.     }
  671.  
  672.     /**
  673.      * Removes a vetoable listener for all event changes.
  674.      * @param listener the listener to remove.
  675.      * @see #addVetoableChangeListener
  676.      */
  677.     public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)
  678.     {
  679.         //super.removeVetoableChangeListener(listener);
  680.         vetos.removeVetoableChangeListener(listener);
  681.     }
  682.  
  683.     /**
  684.      * Used to calculate the hilight colors from the background color.
  685.      * @see #paint
  686.      */
  687.     protected void calculateHilightColors(Color c)
  688.     {
  689.         hilightColor    = ColorUtils.calculateHilightColor(c);
  690.         shadowColor        = ColorUtils.calculateShadowColor(c);
  691.     }
  692.  
  693.     //Protected members
  694.     /**
  695.      * The label text.
  696.      */
  697.     protected String sLabel3D;
  698.  
  699.     /**
  700.      * The current text alignment style.
  701.      * The value is one of: ALIGN_LEFT, ALIGN_CENTERED, or ALIGN_RIGHT.
  702.      * @see #getAlignStyle
  703.      * @see #setAlignStyle
  704.      * @see AlignStyle#ALIGN_LEFT
  705.      * @see AlignStyle#ALIGN_CENTERED
  706.      * @see AlignStyle#ALIGN_RIGHT
  707.      */
  708.     protected int alignStyle;
  709.     /**
  710.      * The current border bevel style.
  711.      * The value is one of: BEVEL_RAISED, BEVEL_LOWERED, BEVEL_LINE, or BEVEL_NONE.
  712.      * @see #getBevelStyle
  713.      * @see #setBevelStyle
  714.      * @see BevelStyle#BEVEL_RAISED
  715.      * @see BevelStyle#BEVEL_LOWERED
  716.      * @see BevelStyle#BEVEL_LINE
  717.      * @see BevelStyle#BEVEL_NONE
  718.      */
  719.     protected int bevelStyle;
  720.     /**
  721.      * The amount to indent around the border: INDENT_ZERO,
  722.      * INDENT_ONE, or INDENT_TWO.
  723.      * @see #getBorderIndent
  724.      * @see #setBorderIndent
  725.      * @see #INDENT_ZERO
  726.      * @see #INDENT_ONE
  727.      * @see #INDENT_TWO
  728.      */
  729.     protected int indent = INDENT_ZERO;
  730.     /**
  731.      * The label text color.
  732.      * @see #getTextColor
  733.      * @see #setTextColor
  734.      */
  735.     protected Color textColor;
  736.     /**
  737.      * The border color.
  738.      * @see #getBorderedColor
  739.      * @see #setBorderedColor
  740.      */
  741.     protected Color borderedColor;
  742.     /**
  743.      * The color of border bevel hilights.
  744.      * This color is automatically determined.
  745.      */
  746.     protected Color hilightColor;
  747.     /**
  748.      * The color of border bevel shawdows.
  749.      * This color is automatically determined.
  750.      */
  751.     protected Color shadowColor;
  752.     /**
  753.      * Cached value of the background color.  Used to determine if calculated colors need to be updated.
  754.      */
  755.     protected Color cachedBackground    = null;
  756.  
  757.     private    VetoableChangeSupport vetos = new VetoableChangeSupport(this);
  758.     private    PropertyChangeSupport changes = new PropertyChangeSupport(this);
  759.  
  760.     transient private FontMetrics fm;
  761.     transient private int xTemp;
  762.     transient private int yTemp;
  763.     transient private boolean bOsFlag = false;
  764. }
  765.  
  766.